package com.oa.modules.approvalsec1.controller;


import cn.hutool.core.lang.hash.Hash;
import cn.hutool.http.HttpRequest;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.google.gson.Gson;
import com.oa.modules.approvalsec1.wx.HttpUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;

@RestController
@Api(tags = "网页唤醒小程序")
@RequestMapping("/wxApp")
public class WxAppController {

    private static final Logger log = LoggerFactory.getLogger(WxAppController.class);


    @ResponseBody
    @ApiOperation(value = "获取小程序链接")
    @GetMapping(value = "/url")
    public static String callApp() {
        String accessToken = WxLoginController.getAccessToken();
        HashMap<String, Object> body = new HashMap<>();
        HashMap<String, Object> jumpWxa = new HashMap<>();
        jumpWxa.put("path","pages/assistant/assistant");
        jumpWxa.put("query","qrcode=1");
        body.put("jump_wxa",jumpWxa);
        String result = HttpRequest.post("https://api.weixin.qq.com/wxa/generatescheme?access_token=" + accessToken)
                .body(JSON.toJSON(body).toString())
                .execute()
                .body();
        return result;
    }

}
